<template>
  <van-cell @click="$router.push(`/detail?id=${item.id}`)">
    <div class="top">
      <!-- <div class="left">1</div> -->
      <img :src="item.avatar" alt="" />
      <div class="right">
        <div class="title">{{ item.stem }}</div>
        <div class="username">
          <span>{{ item.creator }}</span>
          <span>|</span>
          <span>{{ item.createdAt }}</span>
        </div>
      </div>
    </div>
    <div class="middle">
      {{ item.content.replace(/<\/?[^>]+(>|$)/g, "") }}
    </div>
    <div class="bottom">
      <span>点赞 {{ item.likeCount }}</span>
      <span>|</span>
      <span>浏览 {{ item.views }}</span>
    </div>
  </van-cell>
</template>

<script>
export default {
  name: "ArticleItem",
  props: {
    item: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
};
</script>

<style lang="less" scoped>
.top {
  display: flex;

  img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
  }

  .right {
    flex: 1;
    overflow: hidden;
    .username {
      color: #999;
      font-size: 10px;
    }
  }
}

// 超过两行显示省略号
.middle {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: #666;
  font-size: 14px;
}

.bottom {
  color: #999;
  font-size: 10px;
}
span {
  margin-right: 5px;
}
</style>
